﻿<!DOCTYPE html>
<html style="font-size: 50px;">

<head>
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="description" />
    <meta name="keywords" content="车行易,sayhi,app,hi,cxy">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <!-- Set render engine for 360 browser -->
    <meta name="renderer" content="webkit" />
    <meta name="format-detection" content="telephone=no">
    <!-- No Baidu Siteapp-->
    <title>
        Say hi
    </title>

    <script>
        !function (n, e) {
            var t = n.documentElement, i = "orientationchange" in window ? "orientationchange" : "resize", d = function () {
                var n = t.clientWidth;
                if (n) {
                    var e = 50 * (n / 375);
                    //  e = e > 54 ? 54 : e;
                    t.style.fontSize = e + "px";
                }
            };
            n.addEventListener && (e.addEventListener(i, d, !1), n.addEventListener("DOMContentLoaded", d, !1));
        }(document, window);

    </script>

    <link rel="stylesheet" href="css/gold.min.css" type="text/css">
</head>

<body>
    <div class="Mask"></div>
    <div id="goldID" class="gold_content">
        <div class="firstParty relative">
            <div class="todayGetGold">
                <div class="tlt">今天已获得</div>
                <div class="gold"></div>
            </div>
            <div class="signDay">
                <div class="tlt">已连续Say hi</div>
                <div class="day"></div>
            </div>
            <div class="tomorrowGetGold">
                明日Say hi可获得<span></span>
            </div>
            <ul class="weekGetGold">
                <li>
                    <div>？</div>
                    <div>?天</div>
                </li>
            </ul>
            <div class="goldenEntrance hide">
                <div class="hint">今日鼓励金已到手，还可以前往完成鼓励金任务，获取更多鼓励金</div>
                <div class="url">前往参与</div>
            </div>
        </div>
        <!--   <dl class="secondParty relative">
               <dt>Say hi 提醒</dt>
               <dd class="mySwitch" onclick="mySwitchFUN(this)">
                   <div class="mySwitch-inner"></div>
               </dd>
           </dl>-->

    </div>

    <!-- end -->
    <!-- 一次性使用弹窗 -->
    <div class="pop">
        <div class="popBody">
            <div class="popCloseBtn" onclick="popFUN('close')"></div>
            <div class="popContent">
                <p>Say hi获得奖励</p>
                <div class="popExplain">
                    <p>1.连续say hi可获得积分翻倍奖励，连续say hi 7天奖励更多</p>
                    <p>2.连续say hi记录在第8天开始时清零重新计算</p>
                    <p>3.如果中断签到，连续签到也将清零</p>
                    <p>4.本活动最终解释权归车行易所有</p>
                </div>
                <div class="popBtn" onclick="popFUN('close')">好的，我知道了</div>
            </div>
        </div>
    </div>



    <script src="js/cxytongjiV1.js"></script> <!-- 埋点 -->
    <script src="js/jquery.min.js"></script>

    <script src="js/toastV3.min.js"></script>
    <script src="js/JsAPI_NoShare_V1.1.min.js"></script>

    <script language="javascript">

        var production = window.location.href.indexOf("webservice.cx580.com/") > -1 ? true : false; //是否为生产环境
        var baseUrl = production ? "https://webservice.cx580.com" : "http://192.168.1.166:7070";// 请求接口的正式环境和测环境


        /* ===========    常用事件          =================== */
        // 版本号判断和单点登录,返回字符串小写
        function TypeOfBrowser() {
            var channel = "";
            //支付宝
            if (navigator.userAgent.indexOf("AlipayClient") !== -1) {
                channel = "alipay";
            }
            else if (navigator.userAgent.indexOf("appname_cxycwz") > -1) {
                channel = "app";
            }
            else if (navigator.userAgent.indexOf("MicroMessenger") > -1) {
                channel = "weixin";
            }
            else if (navigator.userAgent.indexOf("QQ") > -1) {
                channel = "qq";
            }
            else {
                channel = "unknown";
            }
            return channel;
        }


        // 获取cookie
        function getCookie(name) {
            var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
            if (arr = document.cookie.match(reg))
                return unescape(arr[2]);
            else
                return null;
        }

        //获取url中的参数
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(r[2]); return null; //返回参数值
        }


        /* ===========    事件          =================== */


        // 初始化请求:获取一周的签到时间表
        function initFUN(token) {
            AW.toast.show({
                message: '<div class="toastHits">请稍等...</div>',
                type: 'none',
                callContainer: true
            });

            var param = {
                token: token
            };
            $.ajax({
                url: baseUrl + "/sayHi/getSignDateList",
                type: "GET",
                data: param,
                beforeSend: function () { },
                success: function (res) {
                    //  res = JSON.parse(res);

                    if (res.code == "1000") {
                        var data = res.data;

                        // 提醒开关:可有可无
                        data.signSwitch && $(".mySwitch").hasClass("checkY");


                        // 今天：积分、奖励金
                        popWordFUN(JSON.parse(data.encourageGold));
                        var encourageGold = JSON.parse(data.encourageGold) ?
                            ['<span class="E">' + data.encourageGold + '&nbsp元鼓励金</span>&nbsp', '+' + data.nextEncourageGold + '元鼓励金']
                            : ['', ''];

                        $('.todayGetGold .gold').html('<span class="G">' + data.gold + '&nbsp积分</span>&nbsp' + encourageGold[0] + '<i onClick="popFUN(\'open\')">&nbsp</i>');

                        // 明天：积分、奖励金

                        $('.tomorrowGetGold span').html(data.nextGold + '积分' + encourageGold[1]);

                        // 鼓励金入口
                        JSON.parse(data.encourageGold) && $(".goldenEntrance").removeClass("hide");

                        // 连续天数
                        $('.signDay .day').html(data.signDays || '0');

                        //显示页面
                        //    $('.secondParty').fadeIn();


                        // 连续一周奖励
                        var DOMlist = "";
                        for (var i = 0; i < data.signDateList.length; i++) {
                            var item = data.signDateList[i], j = i + 1, signClass = item.signStatus ? "signY" : "signN"; // 是否已经签到

                            DOMlist += "<li class=\"" + signClass + "\">" +
                                     "<div>+" + item.gold + "</div>" +
                                     "<div>" + j + "天</div>" +
                                "</li>";
                        };
                        $(".weekGetGold").html(DOMlist);

                        AW.toast.hide();

                    } else {

                        AW.toast.show({
                            message: '<div class="toastHits">' + res.msg + '</div>',
                            type: 'none',
                            callContainer: true
                        });

                    }

                },
                error: function (err) {
                    AW.toast.show({
                        message: '<div class="toastHits">' + err.msg + '</div>',
                        type: 'none',
                        callContainer: true
                    });
                },
                complete: function () {
                    if ($(".am-toast .toastHits").html() == "请稍等...") {
                        AW.toast.hide();
                    }
                }
            });

        }


        // 弹窗事件
        function popFUN(type) {
            $(".pop").fadeToggle();
        }

        function popWordFUN(num) {
            if (num) {
                $(".popExplain").html('<p>1.连续签到可获得金币和鼓励金翻倍奖励，连续签到7天奖励更多</p>' +
                    '<p>2.say hi获得的鼓励金最高为5元，完成任意一个鼓励金任务后可提现，提现后可继续say hi获得鼓励金</p>' +
                    '<p>3.连续签到记录在第8天开始时清零重新计算</p>' +
                    '<p>4.如果中断sayhi，sayhi获得的积分不清零，但需重头开始sayhi</p>' +
                    '<p>5.本活动最终解释权归车行易所有</p>');
            } else {
                $(".popExplain").html('<p>1.连续say hi可获得积分翻倍奖励，连续say hi 7天奖励更多</p>' +
                    '<p>2.连续say hi记录在第8天开始时清零重新计算</p>' +
                    '<p>3.如果中断sayhi，sayhi获得的积分不清零，但需重头开始sayhi</p>' +
                    '<p>4.本活动最终解释权归车行易所有</p>');
            }
        }

        // 订阅事件
        function mySwitchFUN(id) {

            var signRemindSwitch = $(id).hasClass("checkY") ? 0 : 1; //签到提醒开关，0：不开启，1：开启
            var param = {
                token: getUrlParam('token'),
                signRemindSwitch: signRemindSwitch
            };
            $.ajax({
                url: baseUrl + "/sayHi/subscribe",
                type: "GET",
                data: param,
                beforeSend: function () { },
                success: function (res) {
                    //  res = JSON.parse(res);

                    if (res.code == "1000") {
                        $(id).toggleClass("checkY");
                    } else {

                        AW.toast.show({
                            message: res.msg,
                            type: 'none',
                            callContainer: true
                        });

                    }

                },
                error: function (err) {
                    AW.toast.show({
                        message: err.msg,
                        type: 'none',
                        callContainer: true
                    });
                },
                complete: function () { }
            });
        }

        /* ================   执行 ==================== */
        $(document).ready(function () {
        
            var token = getUrlParam('token');

            var phonetype = TypeOfBrowser();

            if ( phonetype != "app") {
                noShareFun(phonetype);
            }

            var keyPre = production ? '' : 'test_';

            //埋点 :ID, attr1，userType, userId, productUserId
            cxyBuryingPoint("H5_P_HD_EnteResultpage", "进入sayhi结果页", phonetype, getCookie(keyPre + 'userId'), '');


            initFUN(token); //  请求数据

        }); // end

    </script>

</body>


</html>